package com.itheima.manager.web;

import com.itheima.manager.service.IDeleteService;
import com.itheima.manager.service.imp.DeleteServiceImp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "DeleteServlet", value = "/DeleteServlet")
public class DeleteServlet extends HttpServlet {

    private IDeleteService iDeleteService = new DeleteServiceImp();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String id = request.getParameter("id");

        System.out.println(id);
        iDeleteService.detete(Integer.parseInt(id));
        response.sendRedirect("ListServlet");

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           doGet(request,response);
    }
}
